<%-- 
    Document   : finalcheckout
    Author     : Abeer & Thomas
--%>

<%@page import="PaymentClientPackage.PaymentService"%>
<%@page import="PaymentClientPackage.Payment"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<jsp:useBean id="user" class="checkout.CheckoutInfo" scope="session"/>
<jsp:setProperty name="user" property="*"/>

<%@ include file="header.jsp" %>

<!-- Content -->

<div id="container">
	<div id="content" role="main">
		<div id="post-0" class="post error404 not-found">
			<h1 class="entry-title">Checkout</h1>
			<div class="entry-content">
                        <%
                            String cardResponse = null;
                            Payment p = new PaymentService().getPaymentPort();

                            
                            cardResponse = p.authorise(user.getCardHolder(), user.getCardAddress() , user.getCardPostcode(), user.getCardType(), user.getCardNumber(), user.getExpiryMonth(), user.getExpiryYear(), user.getSecurityCode() );
//                            out.println("<font color='red'>Payment Service is currently down, please try again later!<br/>");

                            if(cardResponse == null){
                                out.println("Sorry for the inconvenience.</font>");
                            }
                            else if(cardResponse.length() == 9){
                                out.println("Payment Successful! Your purchase code is:");
                                out.println(cardResponse);
                            }
                            else{
                                out.println("The payment information you have entered is incomplete or wrong:");
                                out.println(cardResponse);
                                out.println("Please <a HREF='checkout.jsp'>return to checkout page</a> and try again");
                            }
                        %>
                        </div><!-- .entry-content -->
		</div><!-- #post-0 -->
	</div><!-- #content -->
</div><!-- #container -->



<!-- /Content -->

<%@ include file="footer.jsp" %>


